﻿namespace _5_NovaAdmin.Infrastructure.EntityConfigurations;

public static class AuditableEntityBuilderExtensions
{
    public static void ConfigureAuditable<T>(this EntityTypeBuilder<T> builder) where T : AuditableEntity<Guid>
    {
        builder.OwnsOne(o => o.CreationAuditInfo, a =>
        {
            a.WithOwner();
            a.Property(p => p.CreateOpId).HasMaxLength(36).HasColumnName("CreateOpId");
            a.Property(p => p.CreateOpName).HasMaxLength(30).HasColumnName("CreateOpName");
            a.Property(p => p.CreateOpDate).HasColumnName("CreateOpDate");
        });
        builder.OwnsOne(o => o.EditAuditInfo, a =>
        {
            a.WithOwner();
            a.Property(p => p.EditOpId).HasMaxLength(36).HasColumnName("EditOpId");
            a.Property(p => p.EditOpName).HasMaxLength(30).HasColumnName("EditOpName");
            a.Property(p => p.EditOpDate).HasColumnName("EditOpDate");
        });
    }
}
